<@pagelet title="小页面测试">
<style>
    .toolbar{height: 40px;padding: 5px;}
    .content{height: 600px;display: flex }
    .content-left{width: 40%;background-color: #2b669a;}
    .content-right{width: 60%;background-color: #2b542c;}
</style>
<div class="toolbar">
    <div class="btn-group" role="group">
        <button type="button" id="btn1" data-src="/base/redirect/modular/pagelet/pagelet-left" data-target=".content-left" class="btn btn-primary"><i class="fa fa-bolt"></i>加载1</button>
        <button type="button" id="btn2" data-src="/base/redirect/modular/pagelet/pagelet-right" data-target=".content-right" class="btn btn-primary"><i class="fa fa-bolt"></i>加载2</button>
    </div>
</div>
<div class="content">
    <div class="content-left"></div>
    <div class="content-right"></div>
</div>
<script>
    (function(){
        var rootScope = {};

        function load(dom,url,callback){
            var scope = {"k1":"v1"};
            dom.empty();
//            dom.load(rober.url(url),callback);
            $.get(rober.url(url)+"?pagelet=1",function(text,status){
                var domWrapper = $('<div></div>')
                domWrapper.html(text);
                var pageletScripts = $('script',domWrapper);
                var scripts = [];
                pageletScripts.each(function(){
                    var content = $(this).html();
                    if(!content)return;
                    content = content.replace(/(^\s*)|(\s*$)/g, "");//去除两端空格
                    if(!content)return;
                    scripts.push($(this).html());
                });
                pageletScripts.remove();
                for(var i=0;i<scripts.length;i++){
                    console.log(scripts[i]);
                    console.log('--');
                }
                console.log('------------------------');
                console.log(domWrapper.html());
                dom.html(domWrapper.html());
                //执行脚本
                var scope1 = {"k2":"v2"};
                for(var i=0;i<scripts.length;i++){
                    eval(scripts[i]);
                }

            });
        }

        $(".btn").click(function(){
            var src = $(this).data("src");
            var target = $(this).data("target");
            if(!src)return;

            load($(target),src,function(){
                console.log("load callback");
            });
        });
    })();




</script>
</@pagelet>